<?php

include_once '../include/user.inc.php';
include_once '../model/user.class.php';
include_once '../shared/common.inc.php';



try {
	//http://192.168.1.175/jsonApi/api/login.php?ln=jack&un=jack&nn=jack&sex=男&pwd=1234&email=monk.jack.lin@gmail.com&$tel=1234&address=afda
	$logName = G('ln');
	$userName = G('un');
	$nickName = G('nn');
	$sex = G('sex');
	$password = G('pwd');
	$email = G('email');
	$tel = G('tel');
	$address = G('address');
	$now = new DateTime();
	$regDate = $now->format('Y-m-d H:i:s');
	
	$uid = md5(utf8_encode($logName.$password.$tel.$regDate));
	$md5_pwd = md5($password);
	
	$user = new User($uid,$logName,$userName,$nickName,$sex,$md5_pwd,$email,$tel,$address,$regDate);
	
	$reg_result = UO::reigster($user);
	
	$arrState = array('ln'=>$logName,'uid'=>$user->password,'regState'=>$reg_result);
	$jsonStr = json_encode($arrState);
	
	echo $jsonStr;
	
}catch (Exception $ex){
	echo json_encode(array('code'=>$ex->getCode(),'msg'=>$ex->getMessage()));
}

